package day230327;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @author 兴趣使然黄小黄
 * @version 1.0
 * @date 2023/3/27 22:23
 */
public class Main1 {

    public static void main(String[] args) throws IOException {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); // 使用缓存流接收
        int n = Integer.parseInt(bf.readLine()); // 读取字符个数
        // 录入字符串
        String[] strings = new String[n];
        for(int i = 0; i < strings.length; i++) {
            strings[i] = bf.readLine();
        }
        // 判断是否为字典序
        boolean isLexicographically = isLexicographically(strings);
        // 判断是否按照长度排序
        boolean isLengths = isLengths(strings);
        // 根据结果打印
        if (isLexicographically && isLengths) {
            System.out.print("both");
        } else if (isLexicographically) {
            System.out.print("lexicographically");
        } else if (isLengths) {
            System.out.print("lengths");
        } else {
            System.out.print("none");
        }
    }

    // 判断是否为字典序排序
    private static boolean isLexicographically(String[] strings) {
        for (int i = 0; i < strings.length-1; i++) {
            if (strings[i].compareTo(strings[i+1]) > 0) {
                return false;
            }
        }
        return true;
    }

    // 判断是否为长度排序
    private static boolean isLengths(String[] strings) {
        for (int i = 0; i < strings.length - 1; i++) {
            if (strings[i].length() > strings[i+1].length()) {
                return false;
            }
        }
        return true;
    }
}
